package SwordForOffer.Problem16;

public class MyReverseList {

    public MyNode reverseListNode(MyNode root){
        if(root == null){
            return null;
        }
        MyNode currentNode = root;
        MyNode NodeTemp1 = null;
        MyNode NodeTemp2 = null;
        if(root.nextNode == null){
            return root;
        }
        while(currentNode.nextNode != null){
            NodeTemp2 = currentNode.nextNode;
            currentNode.nextNode = NodeTemp1;
            NodeTemp1 = currentNode;
            currentNode = NodeTemp2;
        }
        currentNode.nextNode = NodeTemp1;
        return currentNode;
    }

}
class MyNode{
    int data;
    MyNode nextNode;
}
